{% extends 'base/base.html' %}

{% block title %}{{ title }} - 环保监测数据管理系统{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h2">{{ title }}</h1>
        <div>
            <a href="{% url 'monitoring:data_list' %}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> 返回列表
            </a>
        </div>
    </div>
    
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">{{ title }}</h6>
        </div>
        <div class="card-body">
            <form method="post">
                {% csrf_token %}
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="{{ form.category.id_for_label }}" class="form-label">{{ form.category.label }}</label>
                        {{ form.category }}
                        {% if form.category.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.category.errors.0 }}
                        </div>
                        {% endif %}
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="{{ form.location.id_for_label }}" class="form-label">{{ form.location.label }}</label>
                        {{ form.location }}
                        {% if form.location.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.location.errors.0 }}
                        </div>
                        {% endif %}
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4 mb-3">
                        <label for="{{ form.value.id_for_label }}" class="form-label">{{ form.value.label }}</label>
                        {{ form.value }}
                        {% if form.value.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.value.errors.0 }}
                        </div>
                        {% endif %}
                    </div>
                    <div class="col-md-4 mb-3">
                        <label for="{{ form.unit.id_for_label }}" class="form-label">{{ form.unit.label }}</label>
                        {{ form.unit }}
                        {% if form.unit.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.unit.errors.0 }}
                        </div>
                        {% endif %}
                    </div>
                    <div class="col-md-4 mb-3">
                        <label for="{{ form.status.id_for_label }}" class="form-label">{{ form.status.label }}</label>
                        {{ form.status }}
                        {% if form.status.errors %}
                        <div class="invalid-feedback d-block">
                            {{ form.status.errors.0 }}
                        </div>
                        {% endif %}
                    </div>
                </div>
                <div class="mb-3">
                    <label for="{{ form.measured_at.id_for_label }}" class="form-label">{{ form.measured_at.label }}</label>
                    {{ form.measured_at }}
                    {% if form.measured_at.errors %}
                    <div class="invalid-feedback d-block">
                        {{ form.measured_at.errors.0 }}
                    </div>
                    {% endif %}
                </div>
                <div class="mb-3">
                    <label for="{{ form.notes.id_for_label }}" class="form-label">{{ form.notes.label }}</label>
                    {{ form.notes }}
                    {% if form.notes.errors %}
                    <div class="invalid-feedback d-block">
                        {{ form.notes.errors.0 }}
                    </div>
                    {% endif %}
                </div>
                <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                    <button type="submit" class="btn btn-primary">
                        <i class="fas fa-save"></i> 保存
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %} 